//
//  UpdateBadge_Vm.swift
//  Pods
//
//  Created by eme on 2017/3/28.
//
//

import RxSwift
import Result
import SwiftyJSON
import NetWorkCore

/*
 owner:cy
 update:2017年01月12日09:59:33
 info: 更新Update OrderForm_Vc 的Badge
 */
class UpdateBadge_Vm {
    
    /*
     接收返回的数据
     */
    let updateSubject = PublishSubject<Void>()
    let updateSuccess = PublishSubject<Int>()
    /*
     通用设置
     */
    private let disposeBag = DisposeBag()
    
    init() {
        updateSubject.map{ AddCarApi.cartcounts }.emeRequestApiForRegJson()
            .subscribe(onNext: { (result) in
                switch result {
                case .success(let rel):
                    let value = rel.intValue
                    self.updateSuccess.onNext(value)
                    _ = "orderformbadge".openURL(["value":"\(value)"])
                case .failure(let error):
                    print(error)
                    
                }
            }).disposed(by: disposeBag)
    }
    
}
